using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Joy.Erp.BasicArchives.Core.Filters;

namespace Joy.Erp.BasicArchives.ItemMasters
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("BillOfMaterials")]
    [Route("api/basic-archives/bill-of-materials")]
    public partial class BillOfMaterialsController : BasicArchivesController, IBillOfMaterialsAppService
    {
        protected IBillOfMaterialsAppService BillOfMaterialsAppService => LazyServiceProvider.LazyGetRequiredService<IBillOfMaterialsAppService>();

        [HttpGet]
        [Route("{id}")]
        public Task<BillOfMaterialsDto> GetAsync(Guid id)
        {
            return BillOfMaterialsAppService.GetAsync(id);
        }

        [HttpGet]
        [Route("find")]
        public Task<BillOfMaterialsDto> FindAsync(string filter)
        {
            return BillOfMaterialsAppService.FindAsync(filter);
        }

        [HttpGet]
        [Route("find-by-source-key")]
        public Task<BillOfMaterialsDto> FindBySourceKeyAsync(string sourceKey, string sourceType)
        {
            return BillOfMaterialsAppService.FindBySourceKeyAsync(sourceKey, sourceType);
        }

        [HttpGet]
        public Task<PagedResultDto<BillOfMaterialsDto>> GetListAsync(FilterRequestDto input)
        {
            return BillOfMaterialsAppService.GetListAsync(input);
        }

        [HttpPost]
        [Route("query")]
        public Task<PagedResultDto<BillOfMaterialsDto>> QueryAsync(FilterGroupRequestDto input)
        {
            return BillOfMaterialsAppService.QueryAsync(input);
        }

        [HttpGet]
        [Route("get-with-children")]
        public Task<ListResultDto<BillOfMaterialsDto>> GetWithChildrenAsync(Guid parentId, bool recursive = false)
        {
            return BillOfMaterialsAppService.GetWithChildrenAsync(parentId, recursive);
        }

        [HttpPost]
        [Route("get-children")]
        public Task<ListResultDto<BillOfMaterialsDto>> GetChildrenAsync(Guid? parentId, bool recursive = false)
        {
            return BillOfMaterialsAppService.GetChildrenAsync(parentId, recursive);
        }

        [HttpPost]
        public Task<BillOfMaterialsDto> CreateAsync(BillOfMaterialsCreateDto input)
        {
            return BillOfMaterialsAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<BillOfMaterialsDto> UpdateAsync(Guid id, BillOfMaterialsUpdateDto input)
        {
            return BillOfMaterialsAppService.UpdateAsync(id, input);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return BillOfMaterialsAppService.DeleteAsync(id);
        }
    }
}